home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / FPGAWKII.ZIP / EXAMPLE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  1.9 KB  |  62 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include "jtag.h"
  4.  
  5. main()
  6.     {
  7.     int bit1, bit2;
  8.  
  9.     /* declare and create storage for the EPX780 BSDR bits */
  10.     bitstream *bsdr = AllocBits(264);
  11.  
  12.     /* get the TAP and the TAP controller initialized */
  13.     JTAGPortInit();
  14.     HardTAPReset();
  15.  
  16.     /* load the BSDR storage with the contents of the EPX780 BSDR
  17.        so we know what the current state is out there.  This
  18.        will alter the EPX780 BSDR. */
  19.     EPX780SamplePreload( NULL, bsdr );
  20.  
  21.     /* setup macrocell 3 (attached to pin 6) to output a logic 1 */
  22.     SetMacrocellDirection( bsdr, 3, 1 );
  23.     SetMacrocellOutput( bsdr, 3, 1 );
  24.  
  25.     /* setup macrocell 5 (attached to pin 7) as an input */
  26.     SetMacrocellDirection( bsdr, 5, 0 );
  27.  
  28.     /* save the value of the output bit */
  29.     bit1 = GetMacrocellOutput( bsdr, 3 );
  30.  
  31.     /* now reload the EPX780 BSDR with what we got out of it
  32.        plus the modifications we just made. */
  33.     EPX780SamplePreload( bsdr, NULL );
  34.  
  35.     /* then activate the EXTEST and shift out the result into the
  36.        BSDR storage array */
  37.     EPX780Extest( NULL, bsdr );
  38.  
  39.     /* now print the output from macrocell 3 and the input to
  40.        macrocell 5 and see if they match */
  41.     bit2 = GetMacrocellInput( bsdr, 5 );
  42.     if( bit1==bit2 )
  43.         printf( "%d = %d\n", bit1, bit2 );
  44.     else
  45.         printf( "%d != %d\n", bit1, bit2 );
  46.  
  47.     /* now force a logic 0 on the macrocell 3 output and see if it
  48.        turns up on the macrocell 5 input */
  49.     SetMacrocellOutput( bsdr, 3, 0 );
  50.     bit1 = GetMacrocellOutput( bsdr, 3 );
  51.     EPX780SamplePreload( bsdr, NULL );
  52.     EPX780Extest( NULL, bsdr );
  53.     bit2 = GetMacrocellInput( bsdr, 5 );
  54.     if( bit1==bit2 )
  55.         printf( "%d = %d\n", bit1, bit2 );
  56.     else
  57.         printf( "%d != %d\n", bit1, bit2 );
  58.  
  59.     /* now tristate all the EPX780 pins */
  60.     EPX780HighZ();
  61.     }
  62.